<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>hash mode</title>
</head>
<body>
    <ul>
        <li><a href="#/a">/a</a></li>
        <li><a href="#/b">/b</a></li>
        <li><a href="#/c">/c</a></li>
    </ul>
    <div id="app"></div>
    <script>
        //监听浏览器地址栏中hash值的变量，当hash值发生变化后执行回调
        window.addEventListener('hashchange',()=>{
            //通过hash值获取最新的路径名
            let pathname = window.location.hash.slice(1);
            //修改div#app里的内容
            document.getElementById('app').innerHTML = pathname;
        });
    </script>
</body>
</html>